import 'package:flutter/material.dart';

class MyApp3 extends StatefulWidget {
  const MyApp3({super.key});

  @override
  State<MyApp3> createState() => _MyApp3State();
}

class _MyApp3State extends State<MyApp3> {
  // 状态变量
  final name = '张三';
  int age = 20;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // 背景颜色
      // backgroundColor: Colors.blueGrey,
      // 导航栏
      appBar: AppBar(
        // 导航栏标题
        title: Text('有状态组件'),
        // 导航栏背景颜色
        backgroundColor: const Color.fromARGB(255, 232, 10, 10),
      ),
      // 显示图片  组件 居中
      body: Center(
        child: Text(
          '我叫$name,今年$age岁了',
          style: TextStyle(
            fontSize: 20,
            color: Color.fromARGB(255, 54, 4, 236),
          ),
        ),
      ),
      // 浮动按钮
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          // 设置状态
          setState(() {
            age = age + 1;
          });
        },
        child: Icon(Icons.add),
      ),
    );
  }
}
